<?php
require_once("report.php");
class Specific_customer extends Report
{
	function __construct()
	{
		parent::__construct();
	}
	
	public function getDataColumns()
	{
		return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'),  $this->lang->line('reports_total'), $this->lang->line('reports_payment_type'))
		);		
	}
	
	public function getData(array $inputs)
	{
		//$this->db->select('sales.sale_id, doc, sum(quantity_purchased) as items_purchased, CONCAT(first_name," ",last_name) as employee_name, sum(subtotal) as subtotal, sum(payment_amount) as total, payment_type', false);
		$this->db->select('sales.sale_id, doc, sum(payment_amount) as total, sales_payments.payment_type', false);
		//$this->db->from('sales_items_temp');
		$this->db->from('sales');
		$this->db->join('sales_payments','sales.sale_id=sales_payments.sale_id');
		$this->db->join('customer.customers as customers', 'sales.customer_id = customers.person_id');
		$this->db->where('doc BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and customer_id='.$inputs['customer_id']);
		//$this->db->where('customer_id',$inputs['customer_id']);
		$this->db->group_by('sale_id');
		$this->db->order_by('doc');

		$data = array();
		$data['summary'] = $this->db->get()->result_array();
		
		return $data;
	}
	
	public function getSummaryData(array $inputs)
	{
		$this->db->select('sum(payment_amount) as total');
		$this->db->from('sales');
		$this->db->join('sales_payments','sales.sale_id=sales_payments.sale_id');
		$this->db->where('doc BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and customer_id='.$inputs['customer_id']);
		//$this->db->where('customer_id',$inputs['customer_id']);
		return $this->db->get()->row_array();
	}
}
?>